﻿<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE HTML>
<html>
<head>
    <!-- 包含公共的JSP代码片段 -->

    <title>餐馆王平台</title>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <script type="text/javascript" src="${detailUrl}/style/js/jquery.js"></script>
    <script type="text/javascript" src="${detailUrl}/style/js/page_common.js"></script>
    <link href="${detailUrl}/style/css/common_style_blue.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" type="text/css" href="${detailUrl}/style/css/index_1.css"/>
</head>
<body>
<!-- 页面标题 -->
<div id="TitleArea">
    <div id="TitleArea_Head"></div>
    <div id="TitleArea_Title">
        <div id="TitleArea_Title_Content">
            <img border="0" width="13" height="13" src="${detailUrl}/style/images/title_arrow.gif"/> 餐桌列表
        </div>
    </div>
    <div id="TitleArea_End"></div>
</div>


<!-- 过滤条件 -->
<div id="QueryArea">
    <form action="dinnertable" method="get">
        <input type="hidden" name="method" value="findDinnerTableByName">
        <input type="text" name="tableName" title="请输入餐桌名称" value="${tableName}">
        <input type="submit" value="搜索">
    </form>
</div>


<!-- 主内容区域（数据列表或表单显示） -->
<div id="MainArea">
    <table class="MainArea_Content" cellspacing="0" cellpadding="0">
        <!-- 表头-->
        <thead>
        <tr align="center" valign="middle" id="TableTitle">
            <td>编号</td>
            <td>桌名</td>
            <td>状态</td>
            <td>预定时间</td>
            <td>操作</td>
        </tr>
        </thead>
        <!--显示数据列表 -->
        <tbody id="TableData">
        <c:forEach items="${dinnerTableList}" var="dinnerTable" varStatus="VS">
            <form action="${base}/dinnertable" method="post">
                <input type="hidden" name="method" value="updateDinnerTableStatus">
                <input type="hidden" name="tableId" value="${dinnerTable.tableId}"/>
                <input type="hidden" name="tableStatus" value="${dinnerTable.tableStatus}"/>

                <tr class="TableDetail1">
                    <td align="center">${VS.index + 1}</td>
                    <td align="center">${dinnerTable.tableName}</td>
                    <td align="center">
                        <c:if test="${dinnerTable.tableStatus == 0}">空闲</c:if>
                        <c:if test="${dinnerTable.tableStatus == 1}">预约</c:if>


                    </td>

                    <td align="center">
                            <%--如果为空则 不显示 预约时间--%>
                        <c:if test="${dinnerTable.tableScheduledTime == null}">
                            <input type="datetime-local" name="tableScheduledTime"/>
                            <%--         <input type="datetime-local" name="tableScheduledTime"/>                   --%>
                        </c:if>
                            <%--如果不为空有值则 显示 预约时间--%>
                        <c:if test="${dinnerTable.tableScheduledTime != null}">
                            ${dinnerTable.tableScheduledTime}
                        </c:if>

                    </td>
                    <td><c:if test="${dinnerTable.tableStatus == 0}"><input type="submit" class="FunctionButton"
                                                                            style="height: 21px" value="预约"></c:if>
                        <c:if test="${dinnerTable.tableStatus == 1}"><input type="submit" class="FunctionButton"
                                                                            style="height: 21px" value="退桌"></c:if>


                            <%--         onclick="updateDinnerTableStatus(this,${dinnerTable.tableStatus},${dinnerTable.tableScheduledTime})"               --%>

                        <a href="${base}/dinnertable?method=deleteDinnerTableByTableId&tableId=${dinnerTable.tableId}" class="FunctionButton">删除</a>
                    </td>
                </tr>
            </form>
        </c:forEach>

        </tbody>
    </table>

    <!-- 其他功能超链接 -->
    <div id="TableTail" align="center">
        <div class="FunctionButton"><a href="${detailUrl}/table/table-save.jsp">添加</a></div>
    </div>
</div>
</body>

<%--更新订单状态--%>
<script>
    function updateDinnerTableStatus(obj, tableStatus, tableScheduledTime) {
        var time = $("#tableScheduledTime" + tableScheduledTime).val();
        console.log(time);
        location.href = "${base}dinnertable?method=updateDinnerTableStatus&dinnerTableId=" + tableStatus + "&tableScheduledTime=" + time;
    }
</script>
</html>
